package org.jbox2d.testbed.tests;

import org.jbox2d.collision.shapes.CircleDef;
import org.jbox2d.collision.shapes.PolygonDef;
import org.jbox2d.common.Vec2;
import org.jbox2d.dynamics.Body;
import org.jbox2d.dynamics.BodyDef;
import org.jbox2d.testbed.AbstractExample;
import org.jbox2d.testbed.TestbedMain;

public class Test2 extends AbstractExample {
	
	public Test2(TestbedMain parent){
		super(parent);
	}
	
	@Override
	public void create() {
		PolygonDef sd = new PolygonDef();
		sd.setAsBox(50.0f, 10.0f);
		
		BodyDef bd = new BodyDef();
		bd.position = new Vec2(0.0f, -10.0f);
		m_world.createBody(bd).createShape(sd);
		
		PolygonDef[] pd = new PolygonDef[25];
		
		for (int i = 0; i < pd.length; i++) {
			pd[i] = new PolygonDef();
			pd[i].setAsBox(0.2f, 5.0f);
			pd[i].density = 1.0f;
			
			BodyDef bd2 = new BodyDef();
			bd2.position = new Vec2(-20.0f+i*2.0f, 0.0f);
			
			Body body = m_world.createBody(bd2);
			body.createShape(pd[i]);
			body.setMassFromShapes();
		}
		
		CircleDef cd=new CircleDef();
        cd.density=3000.f;
        BodyDef bd3=new BodyDef();
        bd3.isBullet=true;
        bd3.position.set(new Vec2(-25.f,0.f));
        Body body=m_world.createBody(bd3);
        body.createShape(cd);
        body.setLinearVelocity(new Vec2(5.f,0.f));
        body.setAngularVelocity(0);
        body.setMassFromShapes();

	}
	
	
	@Override
	public String getName(){
		return "Test2";
	}

}
